package com.mz.ozy.mvp.presenter;


import android.app.Activity;


import com.mz.ozy.base.BasePresenterImpl;
import com.mz.ozy.mvp.model.ScanModel;
import com.mz.ozy.mvp.view.ScanContract;
import com.mz.ozy.net.MyObserver;
import com.mz.ozy.utils.RxUtil;

import org.json.JSONObject;

import okhttp3.ResponseBody;

/**
 * Created by administrator on 2018/12/3.
 */
public class ScanPresenter extends BasePresenterImpl<ScanContract.View> implements ScanContract.Presenter{

    private ScanModel mModel;

    public ScanPresenter(){
        mModel = new ScanModel();
    }


    @Override
    public void obtainScan(Activity activity, String username) {
        mModel.obtainScan(activity,username)
                .compose(RxUtil.rxSchedulerHelper(mView.<ResponseBody>bindToLifecycle()))
                .subscribe(new MyObserver<JSONObject>(mView){
                    @Override
                    public void onSuccesss(JSONObject jsonObject) {
                        mView.obtainScanSuccess(jsonObject);
                    }
                });
    }
}
